package cn.imvc.app.controllers.order;

import java.sql.Timestamp;
import java.util.Date;

import org.apache.log4j.Logger;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;

import cn.imvc.app.entities.Comments;
import cn.imvc.app.entities.Orders;
import cn.imvc.app.entities.SalesReturn;
import cn.imvc.app.models.CommentsModel;
import cn.imvc.app.models.LoggingModel;
import cn.imvc.core.DialogBean;
import cn.imvc.core.Render;
import cn.imvc.data.domain.ViewRequest;

public class CommentsControllerImpl implements CommentsController {
	static Logger logger = Logger.getLogger(CommentsControllerImpl.class);
	@Autowired
	CommentsModel commentsModel;
	@Autowired
	LoggingModel loggingModel;
	
	public int id;
	public Page<Comments> page;
	public ViewRequest viewRequest;
	public Comments comments;
	private int memberId;
	private String memberName;
	private int goodsId;
	private String goodsName;
	
	public void setId(int id) {
		this.id = id;
	}

	public void setPage(Page<Comments> page) {
		this.page = page;
	}

	public void setViewRequest(ViewRequest viewRequest) {
		this.viewRequest = viewRequest;
	}
	
	public void setComments(Comments comments) {
		this.comments = comments;
	}

	public String search() {
		if(viewRequest == null){
			viewRequest = new ViewRequest();
		}
		viewRequest.getParams().put("_and_c_dot_member_dot_id_eq_number", memberId+"");
		page = commentsModel.find(viewRequest);
		return "comments/search";
	}
	
	public String detail(){
		comments = commentsModel.get(id);
		return "comments/detail";
	}

	public String index() {
		page = commentsModel.find(viewRequest);
		return "comments/index";
	}

	public String show() {
		// TODO Auto-generated method stub
		return null;
	}

	public String editNew() {
		// TODO Auto-generated method stub
		return null;
	}

	public String create() {
		// TODO Auto-generated method stub
		return null;
	}

	public String edit() {
		comments = commentsModel.get(id);
		return "comments/edit";
	}

	public String update() {
		commentsModel.update(comments);
		loggingModel.info(logger, "审核评论："+comments.getContent());
		return Render.json(new DialogBean("200", "审核完成","comments","closeCurrent"));
	}

	public String destroy() {
		// TODO Auto-generated method stub
		return null;
	}

	public String destroyBatch() {
		// TODO Auto-generated method stub
		return null;
	}

	public int getMemberId() {
		return memberId;
	}

	public void setMemberId(int memberId) {
		this.memberId = memberId;
	}

	public String getMemberName() {
		return memberName;
	}

	public void setMemberName(String memberName) {
		this.memberName = memberName;
	}

	public int getGoodsId() {
		return goodsId;
	}

	public void setGoodsId(int goodsId) {
		this.goodsId = goodsId;
	}

	public String getGoodsName() {
		return goodsName;
	}

	public void setGoodsName(String goodsName) {
		this.goodsName = goodsName;
	}

}
